package com.zdemo.inc;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Tester {

	public static void main(String[] args) {
		final ExecutorService exec = Executors.newFixedThreadPool(111);
		final Square square = new Square();
		for(int i = 0; i < 10000; i++) {
			Runnable r = new Runnable() {
				@Override
				public void run() {
					int random = (int) (Math.random() * 1000 + 1);
					Integer len = square.initAndGetLen(random);
					if(random != len.intValue()) {
						System.out.println(random + "," + square.getLengthPair().getHeight());
					} else {
						System.out.println(random + "," + square.getLengthPair().getHeight());
					}
				}
			};
			exec.submit(r);
		}
		
		exec.shutdown();

		while (true) {
			if (exec.isTerminated()) {
				System.out.println("finished!");
				break;
			}
		}
		
	}
}
